<?php 
include_once("inc/connection.php");
include_once("inc/constants.inc.php");
session_start();

if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']))
{
	header("Location: login.php?error=invalid-access");
}

?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"> 
		<title>Smartek online test | Test</title>
		<link rel="SHORTCUT ICON" href="img/disp/favicon.png" />	
		<link rel="stylesheet" href="css/bootstrap.css"  type="text/css"/>
	</head>
	<body>
		<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
		<script src="js/bootstrap.js"></script>
		<script>
			function validate()
			{
				var error = 0;
				var check = $('input[name=test_type]:checked').length;
				if(check==0)
				{	
					error=1;
					alert("Please choose test type");
					
				}
				if(error==0)
				return true
				else
				return false;
			}
			</script>
		
		<div class="container">
			<img src="img/disp/logo.png" alt="">
		</div>
		<div class="container">
			<div class="row pull-right">
				<div class="span4 pull-right" >
					<div class="pull-right">
						<?php 
						if(!isset($_SESSION['name']) || empty($_SESSION['name'])) echo  "<a href='index.php'>Register</a>";
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==1) echo  "Welcome ".$_SESSION['name']."! | <a href='dashboard.php'>Dashboard</a> | <a href='logout.php'>Log out</a>"; 
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==2) echo  "Welcome ".$_SESSION['name']."! | <a href='dashboard.php'>Continue test</a>"; 
						?>
					</div>
				</div>
			</div>
		</div>
		
		<div class="container">
			<hr class="featurette-divider">
		</div>

		<div class="container">
			<div class="row">
				<div class="span12" > <!--pagination-centered-->
					<form method="POST" action="add-update.php" onSubmit="return validate()" >
						
						<?php 
						if(isset($_GET['emptyType']))
							{
								echo "<font color='red'> <h5>*";
							}
						?>
						Please select the question type and continue.</h5></font>
						</br></br>
						<?php
							
							
						
							$result = mysql_query("SELECT * FROM `question_type` WHERE isDeleted='no'");
							
								while($row = mysql_fetch_array($result))
								{	
						?>
								<div class="container">
									<div class="row">						
										<div class="span9">
										<br/>
											<input type="hidden" name="action" value="update">
										    <input type="radio" name="test_type" value="<?php echo $row['QTypeID']; ?>"> <?php echo $row['QType'];  ?>
											<input type="hidden" name="check" value="fromSelectType">
										</div>										
									</div>
								</div>	
						<?php		
								}
								
						?>	
						</br></br>
					   <input type="submit" class="btn" name="submit" value="Continue">
					</form>
				</div>
			</div>
		</div>
		</br></br></br></br></br></br></br></br>
		<div class="container">
			<hr class="featurette-divider">
		</div>
		<div class="container marketing">
      <!-- FOOTER -->
      <footer>
        <p>&copy; 2014 SCS &middot; </p>
      </footer>

    </div><!-- /.container -->
	</body>
</html>